package chain.example.delivery;

import java.util.Optional;
import java.util.stream.Stream;

public enum DeliveryState {
    /**
     * 未支付，没有物流信息
     */
    NOT_PAY(0),
    /**
     * 已下单状态
     */
    PAYED(10),
    /**
     * 店铺已发货
     */
    SHOP(20),
    /**
     * 第三方实际回调信息
     */
    REAL_DELIVERY(30);


    private int state;

    public int getState() {
        return state;
    }

    DeliveryState(int state) {
        this.state = state;
    }

    public static boolean containsState(int state) {
        Optional<DeliveryState> first = Stream.of(DeliveryState.values()).filter(item -> item.state == state).findFirst();
        return first.isPresent();
    }
}
